home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
436_01
/
stringz.h
< prev
next >
Wrap
Text File
|
1994-10-07
|
10KB
|
254 lines
/*************************************************************************
STRINGZ.H -- Function prototypes for STRINGZ.OBJ.
C-callable routines that offer augmented string handling
capabilities. STRINGZ.OBJ is part of INCON.LIB, but also
may be linked separately if you don't need the input
management provided by INCON. Rather than keep track of
several versions of STRINGZ.OBJ, the routines declared
here are all FAR; they may be linked to programs compiled
under any memory model with only a small penalty to
small-code programs, which must still make far calls.
None of the routines in STRINGZ.OBJ allocate memory for
destination strings or check for overflow in copying to them.
The calling routine is responsible for insuring that enough
space is available for the destination strings, including
terminating null bytes.
Only ReplStr and InsStr check whether the destination string
will wrap around at the end of a segment, since the total
length of the destination may grow dynamically.
The buffers supplied to these routines in DestStr and
SrcStr may be identical; only InsStr and ReplStr, due to
the nature of their operations, refuse to continue in that
circumstance. All of the routines, however, return a null
DestStr in certain circumstances, so it is generally better
if DestStr and SrcStr name two different string buffers.
Assembler: Borland TASM 1.01 (tasm /ml/t/w2/z stringz;)
INCON source files and the object and library files created from
them are:
Copyright (c) 1993-94, Richard Zigler.
You may freely distribute unmodified source, object, and library
files, and incorporate them into your own non-commercial software,
provided that this paragraph and the program name and copyright
strings defined in INCON.C are included in all copies.
*************************************************************************/
/****
Function Prototypes
The parameter and return types, and the routine distances,
are all declared "far", so that these routines can be linked
with programs under any memory model.
These routines can handle strings up to 32767 bytes long.
****/
char far * far pascal LeftStr ( char far *, char far *, short );
char far * far pascal MidStr ( char far *, char far *, short, short );
char far * far pascal RightStr ( char far *, char far *, short );
char far * far pascal lJust ( char far *, char far *, short, short );
char far * far pascal cJust ( char far *, char far *, short, short );
char far * far pascal rJust ( char far *, char far *, short, short );
char far * far pascal lTrim ( char far *, char far * );
char far * far pascal rTrim ( char far *, char far * );
char far * far pascal ReplStr ( char far *, char far *, short );
char far * far pascal InsStr ( char far *, char far *, short );
char far * far pascal TemplStr ( char far *, char far *, short );
/*************************************************************************
char far * far pascal LeftStr( DestStr, SrcStr, Num )
char far * DestStr Destination string
char far * SrcStr Source string
short Num Number of characters to copy
Copies Num characters from left end of SrcStr to DestStr returns
pointer to DestStr.
If Num is greater than or equal to the length of SrcStr, all of
SrcStr is copied. If Num is outside the range 1 to 32767,
DestStr is returned null.
**********************************************************************
char far * far pascal MidStr( DestStr, SrcStr, Start, Num )
char far * DestStr Destination string
char far * SrcStr Source string
short Start First character to copy
short Num Number of characters to copy
Copies Num characters from SrcStr to DestStr beginning at Start
in SrcStr; returns pointer to DestStr.
If Start is greater than the length of SrcStr, DestStr is
returned null. If Num is greater than the remainder of SrcStr,
all characters from Start to the end of SrcStr are copied. If
either Start or Num is outside the range 1 to 32767, DestStr
is returned null.
**********************************************************************
char far * far pascal RightStr( DestStr, SrcStr, Num )
char far * DestStr Destination string
char far * SrcStr Source string
short Num Number of characters to copy
Copies Num characters from right end of SrcStr to DestStr;
returns pointer to DestStr.
If Num is greater than or equal to the length of SrcStr, all
of SrcStr is copied. If Num is outside the range 1 to 32767,
DestStr is returned null.
**********************************************************************
char far * far pascal lJust( DestStr, SrcStr, Size, Chr )
char far * DestStr Destination string
char far * SrcStr Source string
short Size Width of field
char Chr "Pad" character
Copies SrcStr to DestStr, left justified in a field of Size
characters; returns pointer to DestStr.
DestStr is padded on the right with Chr. Chr may be any
character, including control codes. Control codes behave as
they normally would, either printing a graphics character or
taking a specific action. If the length of SrcStr is greater
than Size, SrcStr is truncated on the right. If Size is outside
the range 1 to 32767, DestStr is returned null. If SrcStr is
null, DestStr is filled with Size repetitions of Chr.
**********************************************************************
char far * far pascal cJust( DestStr, SrcStr, Size, Chr )
char far * DestStr Destination string
char far * SrcStr Source string
short Size Width of field
char Chr "Pad" character
Copies SrcStr to DestStr, centered in a field of Size
characters; returns pointer to DestStr.
DestStr is padded on the left and right with Chr. Chr may
be any character, with no provision for excluding ASCII control
codes. If the total padding required to center SrcStr is odd,
the extra character is added on the right. If the length of
SrcStr is greater than Size, SrcStr is truncated on the right.
If Size is outside the range 1 to 32767, DestStr is returned
null. If SrcStr is null, DestStr is filled with Size
repetitions of Chr.
**********************************************************************
char far * far pascal rJust( DestStr, SrcStr, Size, Chr )
char far * DestStr Destination string
char far * SrcStr Source string
short Size Width of field
char Chr "Pad" character
Copies SrcStr to DestStr, right justified in a field of Size
characters; returns pointer to DestStr.
DestStr is padded on the left with Chr. Chr may be any
character, including control codes. Control codes behave as
they normally would, either printing a graphics character or
taking a specific action. If the length of SrcStr is greater
than Size, SrcStr is truncated on the right. If Size is outside
the range 1 to 32767, DestStr is returned null. If SrcStr is
null, DestStr is filled with Size repetitions of Chr.
**********************************************************************
char far * far pascal lTrim( DestStr, SrcStr )
char far * DestStr Destination string
char far * SrcStr Source string
Copies SrcStr to DestStr with leading spaces and control
characters removed; returns pointer to DestStr.
**********************************************************************
char far * far pascal rTrim( DestStr, SrcStr )
char far * DestStr Destination string
char far * SrcStr Source string
Copies SrcStr to DestStr with trailing spaces and control
characters removed; returns pointer to DestStr.
**********************************************************************
char far * far pascal ReplStr( DestStr, SrcStr, Start )
char far * DestStr Destination string
char far * SrcStr Source string
short Start Start position
Replaces characters in DestStr with those from SrcStr; returns
pointer to DestStr.
If Start is g